/**
 * @file 场景窗口头文件
 *
 * 场景窗口头文件
 *
 * @author wq1977@gmail.com
 */

#ifndef __SCENARIOS_FORM_H__
#define __SCENARIOS_FORM_H__

#include "wx/wx.h"
#include "TraceForm.h"
#include "ScenariosManager.h"
#include "ScenariosControl.h"
#include "TerminalStateGrid.h"
#include "ScenariosResultGrid.h"
#include "ScenariosControlPanel.h"


DECLARE_EVENT_TYPE(wxEVT_SCENARIO_EXIT, -1)
DECLARE_EVENT_TYPE(wxEVT_SCENARIO_UPDATE,-1)

//const wxEventType wxEVT_SCENARIO_EXIT = wxNewEventType();
//const wxEventType wxEVT_SCENARIO_UPDATE = wxNewEventType();

#define MAX_SCENARIOS_NUM 10

class SttScenarioControl;
class ScenariosForm: public wxMDIChildFrame
{
    DECLARE_DYNAMIC_CLASS(ScenariosForm)
    friend class SttScenarioControl;
    friend class MyApp;
public:
    ScenariosControlPanel *m_ScenariosControlPanel;
    wxDateTime ScenarioStartAt;

ScenariosForm():wxMDIChildFrame(){};
    wxString LastReportPath;
    wxString Daemon;

    int RunningScenariosNum;
    int SuccScenariosNum;
    int FailScenariosNum; 
    StrLongHash ErrStatistic;    

    ScenariosForm(int Seq, wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
    ~ScenariosForm();
    void SetFormIndex(int v){FormIndex=v;};
    void AppendTracer(TraceForm* v){Tracers.Append(v);};
    void RemoveTracer(TraceForm* v){Tracers.DeleteObject(v);};
    bool IsInProgress(){return m_ScenarioControl!=NULL;};
    int GetFormIndex(){return FormIndex;};
    TermControl *GetTermCtrl(int Index);
    int Sf_Id(){return SeqId*MAX_SCENARIOS_NUM+FormIndex;};
    
    SttScenarioControl*GetScenarioControl(){return m_ScenarioControl;};
private:    
    wxList Tracers;
    int FormIndex;
    int SeqId;
    void OnTermNumChange(wxCommandEvent& event);
    void OnDoStart(wxCommandEvent& event);
    void OnDoStop(wxCommandEvent& event);
    void OnDoReport(wxCommandEvent& event);
    void OnTimer(wxTimerEvent& event);
    void OnCaseStyleChange(wxCommandEvent& event);
    void OnScenarioExit(wxEvent& event);
    void OnStartTrace(wxCommandEvent& event);
    void OnClose(wxCloseEvent& event);    
    void OnScenarioUpdate(wxEvent& event);
    void OnDoScenConf(wxCommandEvent& event);
    TerminalStateGrid  *m_TerminalStateGrid;
    ScenariosResultGrid *m_ScenariosResultGrid;
    SttScenarioControl *  m_ScenarioControl;
    wxTimer m_timer;


    DECLARE_EVENT_TABLE();
};

#endif
